{extend name="wap/default_new/base" /}
{block name="resources"}
<link rel="stylesheet" type="text/css" href="__TEMP__/{$style}/public/css/spelling_list.css">
<link rel="stylesheet" type="text/css" href="__TEMP__/{$style}/public/css/components.css">
<link rel="stylesheet" type="text/css" href="__TEMP__/{$style}/public/css/category.css">
{/block}
{block name="goodsHead"}
<section class="head">
	<a class="head_back" href="javascript:window.history.go(-1)"><i class="icon-back"></i></a>
	<div class="head-title"><span style="margin-left: 40px;">{:lang('spell_group_zone')}</span>{include file="wap/default_new/controGroup" /}</div>
</section>
<div style="height: 45px;"></div>
{if condition="$spelling_group_zone_adv['is_use'] eq 1"}
    {if condition="$spelling_group_zone_adv['adv_list'][0]['adv_image'] neq ''"}
	<div class="slick" style="margin:5px 0;">
		<a href="{:__URL($spelling_group_zone_adv['adv_list'][0]['adv_url'])}">
			<img src="{:__IMG($spelling_group_zone_adv['adv_list'][0]['adv_image'])}" style="width:100%;">
		</a>
	</div>
   {/if}
{/if}
{/block}
{block name="main"}
<div class="spelling-block"></div>
<input type="hidden" id="page_count"><!-- 总页数 -->
<input type="hidden" id="page" value="1"><!-- 当前页数 -->
<script type="text/javascript">
$(function(){
	showCategorySecond(1);
})
var is_load = false;
function showCategorySecond(page){
	//设置选中效果
	$("#page").val(page);//当前页
	if(is_load){
		return false;
	}
	is_load = true;
	$.ajax({
		url:"{:__URL('APP_MAIN/Goods/spellingGroupZone')}",
		data:{"page":page},
		success:function(data){
			$("#page_count").val(data['page_count']);//总页数
			is_load = false;
			var html = '';
			if(data['data'].length==0){
				html += '<div class="nothing-data" align="center"><img src="__TEMP__/{$style}/public/images/wap_nodata.png"/><div>没有找到您想要的拼团商品…</div></div>';
			}else{
				/*if(page == 1){
					var html = '';
				}else if(page > 1){
					var html = $('.tablelist-append').html();
				}*/
				html += '<ul>';
				for(var i=0;i<data['data'].length;i++){
					var curr = data['data'][i];
					html += '<li onclick="location.href=\'' + __URL("APP_MAIN/goods/goodsdetail?id=" + curr.goods_id) + '\'">';
						html += '<div>';
							html += '<img src="{:__IMG($default_goods_img)}" class="lazy_load" data-original="' + __IMG(curr.pic_cover_mid) + '" />';
						html += '</div>';
						
						
						html += '<footer>';
							html += '<p>' + curr.goods_name + '</p>';
							html += '<div>	<span class="tuangou-money">￥' + curr.tuangou_money + '</span><br>';
							html += '<span class="original-money">单买价&nbsp;' + curr.promotion_price + '元</span><button>去拼单&nbsp;&gt;</button></div>';
							html += '';
						html += '</footer>';
					html += '</li>';
				}
				html += '</ul>';
			}
			$('.spelling-block').html(html);
			img_lazyload();	
		}
	});
}

//滑动到底部加载
$(window).scroll(function(){
	var totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
	var content_box_height = parseFloat($(".spelling-block").height());
	if(totalheight - content_box_height >= 100){
		if(!is_load){
			var page = parseInt($("#page").val()) + 1;//页数
			var total_page_count = $("#page_count").val(); // 总页数
			if(page > total_page_count){
				return false;
			}else{
				//showCategorySecond(page);
			}
		}
	}
});
</script>
{/block}
{block name="bottom"}{/block}